package javabasics.thread.TortoiseRabbitGame;

public class Tortoise extends Animal {
    @Override
    public void runing() {
        // 跑的距离
        double dis = 0.1;
        length -= dis;//跑完后距离减少
        if (length <= 0) {
            length = 0;
            System.out.println("乌龟获得了胜利");
            //给回调对象赋值，让兔子不要再跑了
            if (calltoback != null) {
                calltoback.win();
            }
        }
        System.out.println("乌龟跑了" + dis + "米，距离终点还有" + (int)length + "米");
        try {
            sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

//    @Override
//    public void run() {
//        runing();
//    }
}
